/*
 * =====================================================================================
 *
 *       Filename:  hash.c
 *
 *    Description:  Experiments with hash table.
 *
 *        Version:  1.0
 *        Created:  Thursday 11 August 2011 07:57:43  IST
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Dilawar Singh (Graduate Student, EE IITB), dilawar@ee.iitb.ac.in
 *      Institute:  IIT Bombay
 *
 * =====================================================================================
 */


#include	<stdio.h>
#include	<stdlib.h>

/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  main
 *  Description:  
 * =====================================================================================
 */
    int
main ( int argc, char *argv[] )
{
    int num = 100;
    
    typedef struct node
    {
        int val;
        struct node* l;
        struct node* r;
    } myNode;

    int numA[num];

    srand(0);

    myNode mn[num];

    int i = 0;
    for(i = 0; i < num; i++)
    {
        mn[i].l = rand();
        mn[i].r = rand();
        mn[i].val = i;
    }

    printf("Printing random values. \n");

#if 0
    for ( i = 0; i < num; i++)
    {
        printf("%d: ", i);
        printf("|- val %d", mn[i].val);
        printf(" l %p", mn[i].l);
        printf(" r %p\n", mn[i].r);
    }
#endif

    /*  Now the hashing */
    long long hash[num];
    for(i =0; i < num;i++)
    {
        hash[i] = ((int)mn[i].l << 3) ^ ((int)mn[i].r << 2);
    }

    printf("\nHashed values.\n");
    for(i=0;i<num;i++) printf("%d\t", hash[i]);


    return EXIT_SUCCESS;
}				/* ----------  end of function main  ---------- */
